<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
	<link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <script src="/houtai/layui/layui.js"></script>
	<link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <script type="text/javascript" src='/houtai/layui/jquery-3.2.1.js'></script>
    <link rel="stylesheet" href="/shop/style/serachalbelSelect/searchableSelect.css">
    <script type="text/javascript" src="/shop/style/serachalbelSelect/jquery.searchableSelect.js"></script>
</head>
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商品管理</a> &raquo; 编辑商品
    </div>
    <!--面包屑导航 结束-->

	<!--结果集标题与导航组件 开始-->
	<div class="result_wrap">
        <div class="result_title">
            <h3>快捷操作</h3>
        </div>
        <div class="result_content">
            <div class="short_wrap">
                <a href=""><i class="fa fa-plus"></i>编辑商品</a>
            </div>
        </div>
    </div>
    <!--结果集标题与导航组件 结束-->
    
    <div class="result_wrap">
        <form action="javascript:void(0);" method="post" id="login_form">
            <table class="add_tab">
                <tbody>
                    <tr>
                        <th><i class="require">*</i>商品名：</th>
                        <td>
                            <textarea type="text" class="lg" name="name">{{$list['name']}}</textarea>
                            <p>请输入商品名</p>
                        </td>
                    </tr>
                    <tr>
                        <th><i class="require"></i>品牌：</th>
                        <td>
                            <select name="bid" id="compayId" style="width:200px">
                                <option value="0">请选择</option>
                                @foreach($brand as $fvo)
                                    <option value="{{$fvo['id']}}" @if($fvo['id'] == $list['bid'])selected @endif>{{$fvo['name_cny']}}</option>
                                @endforeach
                            </select>
                            <p>请选择品牌</p>
                        </td>
                    </tr>
                    <input type="hidden" name="id" value="{{$list['id']}}">
                    <tr>
                        <th></th>
                        <td>
                            <input type="submit" value="提交">
                            <input type="button" class="back" onclick="history.go(-1)" value="返回">
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </div>
    <script>
        $(function(){
            $('#compayId').searchableSelect();
            $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            layui.use('layer', function() {
                $("#login_form").submit(function(){
                    var name = $("textarea[name=name]").val();
                    var bid = $("select[name=bid]").val();
                    var id = $("input[name=id]").val();

                    if(name == ''){
                        layer.msg('请输入商品名');
                        return false;
                    }

                    $.ajax({
                        url: "/shop/good/update",
                        type: 'post',
                        async: false,
                        data: {'name': name, 'bid': bid ,'id':id},
                        success: function (data) {
                            if (data['code'] != 1) {
                                layer.msg(data['msg']);
                            }else{
                                layer.msg(data['msg']);
                                location.href = '/shop/good/index';
                            }

                        },
                    });

                });
            });
        })

    </script>
</body>
</html>